﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects.Data.Update;
using Rhino.Mocks;
using StructureMap;
using Xunit;

namespace DBMigrator.Core.Tests.DbObjects.Data
{
    public class SetTests
    {
        private readonly Set set;
        private readonly ISetValue<object> setValue;

        public SetTests()
        {
            set = new Set();
            setValue = MockRepository.GenerateMock<ISetValue<object>>();
            ObjectFactory.Inject(setValue);
        }

        [Fact]
        public void SetShouldThrowIfColumnNameIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => set.Column<object>(null));
        }

        [Fact]
        public void SetShouldThrowIfColumnNameIsBlank()
        {
            Assert.Throws<ArgumentNullException>(() => set.Column<object>(string.Empty));
        }

        [Fact]
        public void SetShouldSetColumnName()
        {
            var columnName = StringUtil.Random();
            set.Column<object>(columnName);
            Assert.Equal(columnName, set.ColumnName);
        }

        [Fact]
        public void SetShouldSetSetValue()
        {
            set.Column<object>("ColumnName");
            Assert.Equal(setValue, set.SetValue);
        }

        [Fact]
        public void SetShouldReturnSetValue()
        {
            Assert.Equal(setValue, set.Column<object>("ColumnName"));
        }
    }
}
